<div class="login_box b_radius">
    <p><label for="oldPassWord">旧密码:</label><input id="oldPassWord" type="password" /></p>
    <p><label for="newPassWord">重置密码:</label><input id="newPassWord" type="password" /></p>
    <p><label for="passWordTwo">确认密码:</label><input id="passWordTwo" type="password" /></p>
    <button class="b_radius" id='sureUpdatePassword'>确认重置</button>
</div>
<script type="text/javascript">
    $('#sureUpdatePassword').off().on('click', function () {
        if (!$('#oldPassWord').val()) {
            layer.msg('请输入旧密码');
            return;
        }
        if (!$('#newPassWord').val()) {
            layer.msg('请输入重置密码');
            return;
        }
        if (!$('#passWordTwo').val()) {
            layer.msg('请输入确认密码');
            return;
        }
        if ($('#newPassWord').val() != $('#passWordTwo').val()) {
            layer.msg('密码输入不一致');
            return;
        }
        shared.ajaxPost(config.updatePassword, {
            id: $('#userName').val(), pwd: $('#oldPassWord').val(), newPwd: $('#newPassWord').val(),
            newPwdConfirm: $('#passWordTwo').val()
        }, function callback(res) {
            layer.close(popbox);
            layer.msg('登录成功!!!')
            shared.setCookie('token', res.token);
            shared.setCookie('userinfo', res.userinfo);
            // 跳转到首页
            location.href = 'index.html';
        })
    })
</script>